/**
 * hold user web-socket connections.
 */
var users = {};

users.addNew = function(user) {
	"use strict";
	var userId = user.account;
	users[userId] = user;
};

users.del = function(userId) {
	"use strict";
	delete users[userId];
};

/**
 * @param userId
 *            user id, specify which user to send to
 * @param notification
 *            JSON notification string
 */
users.sendNotification = function(userId, notification) {
	"use strict";
	var user = users[userId];
	if (!user) {
		console.error("user " + userId + " not online");
		return;
	}

	var ws = user.ws;
	ws.send(notification);
};

module.exports = users;
